r'''
# 逻辑
---
用user的ID去查transaction, 拿到plan去生成对应的标准

'''

from django.db import models

PLANS = [
        (1, '免费版'),
        (2, '会员版'),
        (3, '尊享版')
    ]

# Create your models here.
class Plans(models.Model):
    '''

    套餐    -plan

    标题    -title

    容量大小    -memory_size

    下载速度    -download_speed

    有效期  -valid_duration
    '''

    plan = models.SmallIntegerField(default=2, choices=PLANS, primary_key=True)
    
    title = models.CharField(max_length=32)
    
    memory_size = models.CharField(max_length=10)
    
    download_speed = models.CharField(max_length=10)
    
    valid_duration = models.CharField(max_length=20)


class User(models.Model):
    '''
    用户ID  -ID

    用户名  -account

    密码    -password

    手机号  -email

    套餐    -plan
    '''
    ID = models.AutoField(primary_key=True)
    
    username = models.CharField(max_length=32)
    
    password = models.CharField(max_length=32)
    
    email = models.EmailField(max_length=32)
    
    mobile_phone = models.CharField(max_length=32)


class Transaction(models.Model):
    '''
    交易ID  -ID
    
    交易人员ID  -user_ID
    
    交易时间    -deal_time
    
    购买套餐    -plan
    
    失效时间    -unvalid_time
    '''
    ID = models.AutoField(primary_key=True)
    
    user_ID = models.BigIntegerField()
    
    deal_time = models.DateTimeField()
    
    plan = models.SmallIntegerField(default=2, choices=PLANS)
    
    unvalid_time = models.DateTimeField()


class Files(models.Model):
    '''
    用户ID  -user_ID 
    
    ID  -ID
    
    路径  -path
    
    文件名称    -name
    
    修改时间    -m_time
    
    文件大小    -size
    
    文件内容    -content
    
    !!!注意插入时要检测是否有同名同父亲的文件夹(用户上传例外)
    '''
    ID = models.AutoField(primary_key=True)

    user_ID = models.BigIntegerField()
    
    path = models.CharField(max_length=200)
    
    name = models.CharField(max_length=100)
    
    m_time = models.DateTimeField()
    
    size = models.CharField(max_length=100)
    
    content = models.BinaryField()



class Public_Src(models.Model):
    '''
    分享链接ID  -ID
    
    用户ID  -user_ID    
    
    上传日期    -upload_time
    
    分享类型    -type
    
    资源ID  -src_ID
    
    获赞数  -num_stars
    '''
    typeList = [
        ('dir', '文件夹'),
        ('file', '文件')
    ]
    
    ID = models.AutoField(primary_key=True)
    
    upload_time = models.DateTimeField()
    
    user_ID = models.BigIntegerField()
    
    type = models.CharField(max_length=32, choices=typeList)
    
    src_path = models.CharField(max_length=200)
    
    num_stars = models.BigIntegerField() 